package cheme.ProcessModel.Interpreter.Parsers;

import cheme.ProcessModel.ProcessModelConstants;

public class  ParserErrorTransform
{
	public static String transform(String original)
	{	
		int endline = original.indexOf(ProcessModelConstants.eol); //end of first line "Encountered "]" at line 1, column 4."
		endline = original.indexOf(ProcessModelConstants.eol, endline + 1); //end of second line "Was expecting one of:"
		
		String workingString = original.substring(endline, original.length() - 1); //remove those fisrt two lines

		workingString = workingString.replace("<STANDARD_UNIT> ...", "");
		
		workingString = workingString.replace("\"", "\'");
		workingString = workingString.replace(ProcessModelConstants.eol, "");
		workingString = workingString.replace(" ", "");
		workingString = workingString.replace("\t", "");
		
		workingString = workingString.replace("...", ", ");
		

		workingString = workingString.substring(0, workingString.length() - 2); //lose the last ", "
		
		
		return ProcessModelConstants.PARSER_ERROR_PREAMBLE + "(" + workingString + ")";
	}
}
